import { request } from "../utils/request";

// 首页数据
export function _homeData() {
  return request({ url: "/v1/index" });
}

// 搜索页数据
export function _searchData() {
  return request({ url: "/v1/search" });
}

// 获取搜索结果
export function _searchResult(keyword) {
  return request({ url: "/v1/search/keywrod", data: { keyword } });
}

// -----------------------品牌---------------------------
export function _brandList(params) {
  return request({ url: "/v1/brand/list", data: params });
}

export function _brandDetail(params) {
  return request({ url: "/v1/brand/detail", data: params });
}

// -----------------------商品---------------------------

// 获取商品总数量
export function _goodsCount() {
  return request({ url: "/v1/goods/count" });
}

// 获取商品列表
export function _goodsList(params) {
  return request({ url: "/v1/goods/list", data: params });
}

// 获取商品详细
export function _goodsDetail(id) {
  return request({ url: "/v1/goods/detail", data: { id } });
}

// 获取相关推荐
export function _goodsRelated(id) {
  return request({ url: "/v1/goods/related", data: { id } });
}

// 获取商品分类
export function _goodsCate(id) {
  return request({ url: "/v1/goods/cate", data: { id } });
}

// 获取人气推荐
export function _goodsHot() {
  return request({ url: "/v1/goods/hot" });
}

// 获取新品首发
export function _goodsNew() {
  return request({ url: "/v1/goods/new" });
}

// -----------------------收藏--------------------

// 添加或取消收藏
export function _addOrDelCollect(params) {
  return request({ url: "/v1/collect/addordel", data: params, method: "POST" });
}

// 获取收藏列表
export function _collectList() {
  return request({ url: "/v1/collect/list" });
}

// --------------------------购物车----------------

// 添加购物车
export function _addCart(params) {
  return request({ url: "/v1/cart/add", data: params, method: "POST" });
}

// 获取购物车列表
export function _cartList() {
  return request({ url: "/v1/cart/list" });
}

// 获取购物车总数量
export function _cartCount() {
  return request({ url: "/v1/cart/count" });
}

// 更新选中商品
export function _cartCheckedUpdate(params) {
  return request({ url: "/v1/cart/checked", data: params, method: "PUT" });
}

// 更新商品数量
export function _cartGoodsUpdate(params) {
  return request({ url: "/v1/cart/goods", data: params, method: "PUT" });
}

// 删除商品
export function _cartDeleteGoods(params) {
  return request({ url: "/v1/cart/goods", data: params, method: "DELETE" });
}

// 确认订单
export function _cartConfirmOrder(params) {
  return request({ url: "/v1/cart/confirm/order", data: params });
}

// -------------------------------地址-----------------

// 获取区域列表
export function _addressRegionList(id) {
  return request({ url: "/v1/address/region/list", data: id });
}

// 添加地址
export function _addressNew(params) {
  return request({ url: "/v1/address/new", data: params, method: "POST" });
}

// 获取地址列表
export function _addressList() {
  return request({ url: "/v1/address/list" });
}

// 获取地址详细
export function _addressDetail(id) {
  return request({ url: "/v1/address/detail", data: id });
}

// 删除地址
export function _addressDelete(id) {
  return request({ url: "/v1/address", data: { id }, method: "DELETE" });
}

// -------------------------------订单--------------------

// 提交订单
export function _orderSubmit(id) {
  return request({ url: "/v1/order/submit", data: id, method: "POST" });
}

// 获取订单列表
export function _orderList(params) {
  return request({ url: "/v1/order/list", data: params });
}

// 获取订单详细
export function _orderDetail(id) {
  return request({ url: "/v1/order/detail", data: id });
}

// ------------------------------专题-----------------

// 获取专题页数据
export function _themeData(params) {
  return request({ url: "/v1/theme", data: params });
}

// 获取专题详细
export function _themeDetail(id) {
  return request({ url: "/v1/theme/" + id });
}

// ---------------------------评论----------------------

// 获取评论
export function _commentList(params) {
  return request({ url: "/v1/comment/list", data: params });
}

// 获取评论总数量
export function _commentCount(params) {
  return request({ url: "/v1/comment/count", data: params });
}

// 添加评论
export function _addComment(params) {
  return request({ url: "/v1/comment/add", data: params, method: "POST" });
}

// -------------------------分类-----------------------------

// 分类页面数据
export function _cateData() {
  return request({ url: "/v1/cate" });
}

// 根据ID获取对应的分类
export function _currentCate(id) {
  return request({ url: "/v1/cate", data: { id } });
}

// -----------------------足迹---------------------------
// 添加足迹
export function _footprintNew(id) {
  return request({ url: "/v1/footprint/new", data: { id }, method: "POST" });
}

// 获取足迹列表
export function _footprintList() {
  return request({ url: "/v1/footprint/list" });
}

// 删除足迹
export function _footprintDelete(id) {
  return request({ url: "/v1/footprint", data: { id }, method: "DELETE" });
}

// ---------------------------------------------------

// 登录
export function _login(params) {
  return request({ url: "/v1/login", data: params, method: "POST" });
}
